package com.cloud.client.controller;

import com.cloud.client.bean.User;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.*;

import java.util.ArrayList;
import java.util.List;


/**
 * @author: zoub
 * @date 2020/10/15 14:50
 **/
@RestController
public class TestController {

    @Value("${server.port}")
    String port;

    @GetMapping("/hi")
    public String hi(@RequestParam(value = "name", defaultValue = "forezp") String name) {
        return "hi，" + name + " ,from port:" + port;
    }

    @GetMapping("/hi/{name}")
    public String hi2(@PathVariable("name") String name) {
        return "hi2，" + name + " ,from port:" + port;
    }

    @PostMapping("/user")
    public User user(@RequestBody User user) {
        user.setName(user.getName() + "，奥利给！" + " ,from port:" + port);
        return user;
    }

    @GetMapping("/getList")
    public List<User> getList() {
        List<User> list = new ArrayList();
        list.add(new User(1001, "张三"));
        list.add(new User(1002, "李四"));
        list.add(new User(1003, "王五"));
        return list;
    }


}
